package com.example.langchain4jdemo.model;

import lombok.Data;

@Data
public class ApiResult<T> {
    private Integer code;   // 1 成功，0 失败
    private String  msg;
    private T       data;

    public static <T> ApiResult<T> success() {
        return new ApiResult<>(1, "success", null);
    }

    public static <T> ApiResult<T> success(T data) {
        return new ApiResult<>(1, "success", data);
    }

    public static <T> ApiResult<T> success(T data, String msg) {
        return new ApiResult<>(1, msg, data);
    }

    public static <T> ApiResult<T> fail() {
        return new ApiResult<>(0, "fail", null);
    }

    public static <T> ApiResult<T> fail(String msg) {
        return new ApiResult<>(0, msg, null);
    }

    private ApiResult(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
}